package com.zyj.java2;

/**
 * @program: JVMDemo
 * @ClassName StackAllocation
 * @author: YaJun
 * @Date: 2021 - 12 - 15 - 9:20
 * @Package: com.zyj.java2
 * @Description:
 * 栈上分配 + 逃逸分析
 * -Xms1g -Xmx1g -XX:-DoEscapeAnalysis -XX:+PrintGCDetails
 */
public class StackAllocation {

    public static void main(String[] args) {

        long start = System.currentTimeMillis();

        for (int i = 0; i < 10000000; i++) {
            alloc();
        }

        // 查看执行时间
        long end = System.currentTimeMillis();
        System.out.println("花费的时间为：" + (end - start) + "ms");

        try {
            Thread.sleep(1000000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

    private static void alloc() {
        User user = new User();
    }


}
